using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;

namespace SideShow.Scf.ObjectModel
{
    [Serializable]
    public enum ScfButtonKey
    {
        [XmlEnum("enter")]
        Enter,
        [XmlEnum("back")]
        Back,
        [XmlEnum("home")]
        Home,
        [XmlEnum("left")]
        Left,
        [XmlEnum("right")]
        Right
    }

    [Serializable]
    public class ScfButton : ScfObject
    {
        private ScfButtonKey _key;
        private uint _targetId;

        public ScfButtonKey Key
        {
            get { return _key; }
            set { _key = value; }
        }

        public uint TargetId
        {
            get { return _targetId; }
            set { _targetId = value; }
        }

        protected internal override void DeserializeFromXml(System.Xml.XmlNode node)
        {
            base.DeserializeFromXml(node);
            _key = GetAttribute<ScfButtonKey>(node, "key");
            _targetId = GetAttribute<uint>(node, "target");
        }

        protected internal override void SerializeObject(System.IO.BinaryWriter writer)
        {
            base.SerializeObject(writer);
            writer.Write((int)_key);
            writer.Write(_targetId);
        }

        protected internal override void DeserializeObject(System.IO.BinaryReader reader)
        {
            base.DeserializeObject(reader);
            _key = (ScfButtonKey)reader.ReadUInt32();
            _targetId = reader.ReadUInt32();
        }
    }
}
